package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.domain.Goods;
import com.service.goodsService;

public class goodsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public goodsServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//接收url中的汉字字段
		String goods_sorts=new String(request.getParameter("goods_sorts").getBytes("iso8859-1"),"utf-8");
		//
		goodsService goodsService = new goodsService();
		//用接受的字段用来当作查询的条件，返回的结果放入goods中
		List<Goods> goodsList = goodsService.goodsListService(goods_sorts);//所有的数据
		/*System.out.println(goods);*/
		
		
		HttpSession session = request.getSession();
		session.setAttribute("goods", goodsList);
		session.setAttribute("goods_sorts", goods_sorts);
		
		response.sendRedirect("goods.jsp");
		
	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
